﻿Shader "custom/intermediate/cutaways_discard_sprite_4" {
	Properties {
		//[PerRendererData]
		 _MainTex("Sprite Texture" , 2D) = "white" { }
		_threshold("threshold",Range(-1.0,1.0)) = 0.0
	}
	SubShader {
		 Tags{
		 		
		 }
		Cull Off
		Lighting Off
		ZWrite Off
		Fog { Mode Off }
		Offset -1, -1
		Blend SrcAlpha OneMinusSrcAlpha
		Pass {
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			uniform sampler2D _MainTex;
			uniform float _threshold;
			
			struct vertexInput{
					float4 vertex   : POSITION;
					float4 color    : COLOR;
					float2 texcoord : TEXCOORD0;
			};
			struct vertexOutput{
					float4 pos        : SV_POSITION;
					float4 posObject : TEXCOORD1;
					float4 color    : COLOR;
					float2 texcoord  : TEXCOORD0;
			};
			
			vertexOutput vert(vertexInput i)
			{
				vertexOutput o;
				o.pos = mul(UNITY_MATRIX_MVP, i.vertex);
				o.posObject = i.vertex;
				o.color = i.color;
				o.texcoord = i.texcoord;
				return o;
			}
			
			float4 frag(vertexOutput o):SV_Target
			{
				if(o.posObject.y > _threshold) {
					discard;
				} //  according to the pivot ingore scale
				
				//float3 right = (0.0, 0.0, 1.0);
				//float3 pos = normalize(o.posObject);
				//if(dot(o.posObject,right) > 0.0) {
				//	discard;
				//}								
				fixed4 c = tex2D(_MainTex, o.texcoord.xy) ;
				return c;
				//return float4(float3(c.rgb),0.0);
			}
			ENDCG
		}
	} 
}
